//
//  FGYTabBarViewController.m
//  01 - shop
//
//  Created by ma c on 16/8/17.
//  Copyright (c) 2016年 beijing. All rights reserved.
//

#import "FGYTabBarViewController.h"
#import "FGYBuyCatViewController.h"
#import "FGYClassViewController.h"
#import "FGYMyViewController.h"
#import "FGYTimeViewController.h"
#import "FGYNavigationViewController.h"

@interface FGYTabBarViewController ()

@property (strong, nonatomic) NSArray * dataArray;

@end

@implementation FGYTabBarViewController

- (NSArray *)dataArray{
    if (!_dataArray) {
        NSString * path = [[NSBundle mainBundle]pathForResource:@"FGYTabBarViewController.plist" ofType:nil];
        _dataArray = [NSArray arrayWithContentsOfFile:path];
    }
    return _dataArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:56 / 255.0 green:165 / 255.0 blue:241 / 255.0 alpha:1]} forState:UIControlStateSelected];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:132 / 255.0 green:132 / 255.0 blue:132 / 255.0 alpha:1]} forState:UIControlStateNormal];
    
    for (NSDictionary * dict in self.dataArray) {
        Class view = NSClassFromString(dict[@"viewController"]);
        UIViewController * controller = [[view alloc]init];
        
        FGYNavigationViewController * nav = [[FGYNavigationViewController alloc]initWithRootViewController:controller];
        controller.tabBarItem.image = [UIImage imageNamed:dict[@"image"]];
        controller.tabBarItem.selectedImage = [UIImage imageNamed:dict[@"selectImage"]];
        controller.title = dict[@"title"];
        [self addChildViewController:nav];
    }
    
}

@end
